var e = require;
var t = module;
var n = exports;
var o,
    i =
    (this && this.__extends) ||
    ((o = function(e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(e, t) {
                        e.__proto__ = t;
                    }) ||
                function(e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function(e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
    (this && this.__decorate) ||
    function(e, t, n, o) {
        var i,
            r = arguments.length,
            a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
        else
            for (var s = e.length - 1; 0 <= s; s--)
                (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
        return 3 < r && a && Object.defineProperty(t, n, a), a;
    },
    a =
    (this && this.__awaiter) ||
    function(e, a, s, c) {
        return new(s = s || Promise)(function(n, t) {
            function o(e) {
                try {
                    r(c.next(e));
                } catch (e) {
                    t(e);
                }
            }

            function i(e) {
                try {
                    r(c.throw(e));
                } catch (e) {
                    t(e);
                }
            }

            function r(e) {
                var t;
                e.done ?
                    n(e.value) :
                    ((t = e.value) instanceof s ?
                        t :
                        new s(function(e) {
                            e(t);
                        })
                    ).then(o, i);
            }
            r((c = c.apply(e, a || [])).next());
        });
    },
    s =
    (this && this.__generator) ||
    function(n, o) {
        var i,
            r,
            a,
            s = {
                label: 0,
                sent: function() {
                    if (1 & a[0]) throw a[1];
                    return a[1];
                },
                trys: [],
                ops: []
            },
            e = { next: t(0), throw: t(1), return: t(2) };
        return (
            "function" == typeof Symbol &&
            (e[Symbol.iterator] = function() {
                return this;
            }),
            e
        );

        function t(t) {
            return function(e) {
                return (function(t) {
                    if (i) throw new TypeError("Generator is already executing.");
                    for (; s;)
                        try {
                            if (
                                ((i = 1),
                                    r &&
                                    (a =
                                        2 & t[0] ?
                                        r.return :
                                        t[0] ?
                                        r.throw || ((a = r.return) && a.call(r), 0) :
                                        r.next) &&
                                    !(a = a.call(r, t[1])).done)
                            )
                                return a;
                            switch (((r = 0), (t = a ? [2 & t[0], a.value] : t)[0])) {
                                case 0:
                                case 1:
                                    a = t;
                                    break;
                                case 4:
                                    return s.label++, { value: t[1], done: !1 };
                                case 5:
                                    s.label++, (r = t[1]), (t = [0]);
                                    continue;
                                case 7:
                                    (t = s.ops.pop()), s.trys.pop();
                                    continue;
                                default:
                                    if (!(a = 0 < (a = s.trys).length && a[a.length - 1]) &&
                                        (6 === t[0] || 2 === t[0])
                                    ) {
                                        s = 0;
                                        continue;
                                    }
                                    if (3 === t[0] && (!a || (t[1] > a[0] && t[1] < a[3]))) {
                                        s.label = t[1];
                                        break;
                                    }
                                    if (6 === t[0] && s.label < a[1]) {
                                        (s.label = a[1]), (a = t);
                                        break;
                                    }
                                    if (a && s.label < a[2]) {
                                        (s.label = a[2]), s.ops.push(t);
                                        break;
                                    }
                                    a[2] && s.ops.pop(), s.trys.pop();
                                    continue;
                            }
                            t = o.call(n, s);
                        } catch (e) {
                            (t = [6, e]), (r = 0);
                        } finally {
                            i = a = 0;
                        }
                    if (5 & t[0]) throw t[1];
                    return { value: t[0] ? t[1] : void 0, done: !0 };
                })([t, e]);
            };
        }
    };
Object.defineProperty(n, "__esModule", { value: !0 });
var c,
    l = e("Excelchallenge_area1"),
    u = e("index"),
    p = e("player-info"),
    h = e("player-war"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
    ((c = cc.Component),
        i(d, c),
        (d.prototype.start = function() {}),
        (d.prototype.init = function(e) {
            (this.curIdx = e), l.default.GetLine(this.curIdx + 1);
            e = h.playerWar.getWarLevelTime(this.curIdx);
            (this.label.spriteFrame = this.labelSpriteFrames[this.curIdx]),
            e <= 0 ?
                ((this.time.string = ""), (this.time.node.parent.active = !1)) :
                ((this.time.string = Math.floor(e / 60) + "分" + (e % 60) + "秒"),
                    (this.time.node.parent.active = !0));
            e = h.playerWar.getWarLevelUnlock(this.curIdx);
            this.lockNode.active = !e;
        }),
        (d.prototype.callBack = function() {
            var e = h.playerWar.getWarLevelUnlock(this.curIdx);
            e
                ?
                (h.playerWar.setWarLevel(this.curIdx),
                    h.playerWar.setIsGuideLevel(0 === this.curIdx),
                    this.enterGame()) :
                console.log("error callBack...", e);
        }),
        (d.prototype.enterGame = function() {
            return a(this, void 0, void 0, function() {
                var t = this;
                return s(this, function(e) {
                    switch (e.label) {
                        case 0:
                            return (
                                e.trys.push([0, 1, , 3]),
                                p.playerInfo.setGameType(p.gameType.war),
                                cc.director.loadScene("game", function() {
                                    var e = h.playerWar.getWarLevelCount(t.curIdx);
                                    h.playerWar.setWarLevelCount(t.curIdx, e + 1),
                                        u.platform.trackEvent("start_challenge", { level: t.curIdx + 1, number: e + 1 });
                                }), [3, 3]
                            );
                        case 1:
                            return (
                                e.sent(), [
                                    4,
                                    u.platform.showModal({
                                        title: "友情提示",
                                        content: "加载游戏场景出现问题，请退出重试",
                                        confirmText: "确定",
                                        showCancel: !1
                                    })
                                ]
                            );
                        case 2:
                            return e.sent(), [3, 3];
                        case 3:
                            return [2];
                    }
                });
            });
        }),
        (d.prototype.onAdsLockCallBack = function() {
            var e = h.playerWar.getWarLevelUnlock(this.curIdx);
            e
                ?
                console.log("error unlock...", e) :
                (console.log("unlock....", this.curIdx),
                    h.playerWar.setWarLevelUnlock(this.curIdx, !0),
                    u.platform.trackEvent("unlock_challenge", { level: this.curIdx + 1 }),
                    (this.node.getComponent(cc.Button).interactable = !0),
                    (this.lockNode.active = !1),
                    this.callBack());
        }),
        (d.prototype.unlock = function() {}),
        r([t(cc.Sprite)], d.prototype, "label", void 0),
        r([t(cc.Label)], d.prototype, "time", void 0),
        r([t(cc.Node)], d.prototype, "lockNode", void 0),
        r([t([cc.SpriteFrame])], d.prototype, "labelSpriteFrames", void 0),
        r([e], d));

function d() {
    var e = (null !== c && c.apply(this, arguments)) || this;
    return (e.label = null), (e.time = null), (e.lockNode = null), (e.labelSpriteFrames = []), (e.curIdx = 0), e;
}
n.default = e;